package com.skirmisher.inspection.common.service.impl;

import com.skirmisher.inspection.common.entity.InsFile;
import com.skirmisher.inspection.common.entity.InsUser;
import com.skirmisher.inspection.common.mapper.InsFileMapper;
import com.skirmisher.inspection.common.service.InsFileService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.*;

/**
 * @ClassName InsFileServiceImpl
 * @Description TODO
 * @Author hanwangxin
 * @Date 2020/12/14 下午7:50
 * @Version 1.0
 */
@Slf4j
@Transactional
@Service
public class InsFileServiceImpl implements InsFileService {

    @Autowired
    private InsFileMapper insFileMapper;

    @Override
    public void saveFile(InsFile insFile) {

        insFile.setId(UUID.randomUUID().toString());
        insFile.setInTime(new Date());
        insFileMapper.insert(insFile);
    }

    @Override
    public List<InsFile> getFileList(String bindId) {
        List<InsFile> files = insFileMapper.getFileList(bindId);
        return files;
    }

    @Override
    public void getUser(InsUser user) {
        List<Object> dateList = insFileMapper.getUserList(user);
        int count  = insFileMapper.getUserCount(user);
        user.setDateList(dateList);
        user.setCount(count);
    }
}
